<html>
<head><meta charset="utf-8"><title>Making `unconditional_recursion` work across function calls · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html">Making `unconditional_recursion` work across function calls</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="205684012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205684012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205684012">(Aug 01 2020 at 14:34)</a>:</h4>
<p>It's that time of the year again, so I have started to look into <a href="https://github.com/rust-lang/rust/issues/57965">#57965</a> again (seriously this time). I think I have most of the linting logic figured out, but am now hitting issues where it tried to read from stolen MIR.</p>
<p>I have split up <code>mir_built</code> into two queries to be able to run the lint right after MIR building (just like it is now), but without introducing cycles where the lint requests MIR of a called function, which then runs the lint on that function, which then requests the MIR of the original caller again. I'm not sure if this is the best way to do it, but it should work.</p>
<p>The problem now is that MIR may be optimized or otherwise analyzed, which steals the MIR from the <code>mir_built</code> query. If some unrelated function is then linted, the unoptimized MIR will be requested, which has been stolen. Any suggestions for getting around this?</p>



<a name="205684840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205684840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205684840">(Aug 01 2020 at 14:56)</a>:</h4>
<p>I guess I can add <code>Steal::is_stolen</code> and fall back to <code>optimized_mir</code>, which should always exist then...</p>



<a name="205685168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685168">(Aug 01 2020 at 15:04)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> you're solving the same problem as I'm solving for inlining</p>



<a name="205685171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685171">(Aug 01 2020 at 15:04)</a>:</h4>
<p>I think so, yes</p>



<a name="205685179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685179">(Aug 01 2020 at 15:05)</a>:</h4>
<p>There's an impl in <a href="https://github.com/rust-lang/rust/pull/68828">https://github.com/rust-lang/rust/pull/68828</a></p>



<a name="205685181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685181">(Aug 01 2020 at 15:05)</a>:</h4>
<p>which gives you all the info you are looking for</p>



<a name="205685233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685233">(Aug 01 2020 at 15:06)</a>:</h4>
<p>then you can "just not" request the <code>optimized_mir</code> of a function if you know that's gonna cause a cycle</p>



<a name="205685235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685235">(Aug 01 2020 at 15:06)</a>:</h4>
<p>and if <code>mir_inliner_cycle</code> returns <code>None</code>, you don't need to do anything anyway</p>



<a name="205685249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685249">(Aug 01 2020 at 15:07)</a>:</h4>
<p>Ah, so does that just run inlining before any other optimizations?</p>



<a name="205685254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685254">(Aug 01 2020 at 15:07)</a>:</h4>
<p>nope</p>



<a name="205685256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685256">(Aug 01 2020 at 15:07)</a>:</h4>
<p>it computes the call graph before any other optimizations</p>



<a name="205685261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685261">(Aug 01 2020 at 15:07)</a>:</h4>
<p>so as long as const prop or something else doesn't start devirtualizing function calls, we're fine</p>



<a name="205685303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685303">(Aug 01 2020 at 15:08)</a>:</h4>
<p>and when we start devirtualizing we need some fancy scheming anyway</p>



<a name="205685309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685309">(Aug 01 2020 at 15:08)</a>:</h4>
<p>oh, okay</p>



<a name="205685321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685321">(Aug 01 2020 at 15:09)</a>:</h4>
<p>the perf results aren't too bad (up to 4% in some cases), so if we have two good uses cases for it, maybe we can argue for taking the perf hit</p>



<a name="205685322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685322">(Aug 01 2020 at 15:09)</a>:</h4>
<p>i thought we could just solve inlining cycles by splitting the optimization pipeline into distinct queries</p>



<a name="205685328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685328">(Aug 01 2020 at 15:09)</a>:</h4>
<p>and then use the early query before and in inlining, and the later query afterwards</p>



<a name="205685329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685329">(Aug 01 2020 at 15:09)</a>:</h4>
<p>that's not too great, we'll want to run inlining and const prop in a loop until we reach a fixed point I think</p>



<a name="205685373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685373">(Aug 01 2020 at 15:10)</a>:</h4>
<p>it also has the same problems wrt devirtualization</p>



<a name="205685375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685375">(Aug 01 2020 at 15:10)</a>:</h4>
<p>and I have no idea on the perf implications</p>



<a name="205685381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685381">(Aug 01 2020 at 15:10)</a>:</h4>
<p>maybe we should just request a compiler design meeting on this?</p>



<a name="205685387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685387">(Aug 01 2020 at 15:10)</a>:</h4>
<p>hmm, yeah</p>



<a name="205685391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685391">(Aug 01 2020 at 15:10)</a>:</h4>
<p>idk, I haven't looked into this much</p>



<a name="205685401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685401">(Aug 01 2020 at 15:11)</a>:</h4>
<p>oh and I think the problem you're encountering now would still happen in the inlining split case ^^</p>



<a name="205685406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685406">(Aug 01 2020 at 15:11)</a>:</h4>
<p>fixed-point inlining? that does sound cursed</p>



<a name="205685451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685451">(Aug 01 2020 at 15:12)</a>:</h4>
<p>well... if we really want to take away work from llvm, we gotta do something like that</p>



<a name="205685468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205685468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205685468">(Aug 01 2020 at 15:12)</a>:</h4>
<p>we'll get a big gain just by normal inlining, but only if that inlining doesn't use the split scheme, otherwise we only ever inline a single level I think</p>



<a name="205693682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205693682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205693682">(Aug 01 2020 at 18:52)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error: internal compiler error: src/librustc_mir/interpret/eval_context.rs:268:21: expected type differs from actual type.
expected: &amp;mut std::string::String
actual: &amp;std::string::String
  --&gt; /home/jonas/dev/rust/src/test/ui/span/mut-arg-hint.rs:14:5
   |
LL | /     pub fn foo(mut a: &amp;String) {
LL | |         a.push_str(&quot;foo&quot;); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&amp;` reference
LL | |     }
   | |_____^
</code></pre></div>


<p>no idea how this one's even possible</p>



<a name="205693770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205693770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205693770">(Aug 01 2020 at 18:54)</a>:</h4>
<p>oh, I guess requesting the optimized MIR is not a good idea when there's type errors</p>



<a name="205694219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205694219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205694219">(Aug 01 2020 at 19:07)</a>:</h4>
<p>Is there a way to find out if any <em>fatal</em> errors were reported? <code>Session::has_errors</code> will return true even if it just has errors because of a <code>deny</code>d lint.</p>



<a name="205694411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205694411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205694411">(Aug 01 2020 at 19:13)</a>:</h4>
<p>not sure if <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckResults.html#structfield.tainted_by_errors">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckResults.html#structfield.tainted_by_errors</a> suffices for your case</p>



<a name="205701177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205701177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205701177">(Aug 01 2020 at 22:41)</a>:</h4>
<p>that helps, yeah :)</p>



<a name="205701227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205701227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205701227">(Aug 01 2020 at 22:43)</a>:</h4>
<p>now the remaining issue to make this useful: <code>Instance::resolve</code> will ICE when it can't fully normalize the result</p>



<a name="205701279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205701279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205701279">(Aug 01 2020 at 22:44)</a>:</h4>
<p>this is a problem because I may pass semi-monomorphized substs to it that allow the <em>instance</em> to be resolved to a concrete function item, but that function might still contain generic types (and thus unnormalizable projections)</p>



<a name="205703061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205703061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205703061">(Aug 01 2020 at 23:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls/near/205694411">said</a>:</p>
<blockquote>
<p>not sure if <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckResults.html#structfield.tainted_by_errors">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckResults.html#structfield.tainted_by_errors</a> suffices for your case</p>
</blockquote>
<p>actually no, this still seems to give the same error</p>



<a name="205704587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205704587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205704587">(Aug 02 2020 at 00:39)</a>:</h4>
<p>okay so now I have</p>
<div class="codehilite"><pre><span></span><code>error: function cannot return without recursing
  --&gt; $DIR/lint-unconditional-recursion.rs:152:1
   |
LL | fn cycle1() {
   | ^^^^^^^^^^^ cannot return without recursing
LL |     cycle2();
   |     -------- call into the next function in the cycle
...
LL |     cycle1();
   |     -------- call site completing the cycle
   |
note: next function in the cycle
  --&gt; $DIR/lint-unconditional-recursion.rs:156:1
   |
LL | fn cycle2() {
   | ^^^^^^^^^^^
</code></pre></div>


<p>which looks odd, since the labels are getting reordered in a way that's hard to read. I'd like to have something like this:</p>
<div class="codehilite"><pre><span></span><code>error: function cannot return without recursing
  --&gt; $DIR/lint-unconditional-recursion.rs:152:1
   |
LL | fn cycle1() {
   | ^^^^^^^^^^^ cannot return without recursing
LL |     cycle2();
   |     -------- call into the next function in the cycle
   |
note: next function in the cycle
  --&gt; $DIR/lint-unconditional-recursion.rs:156:1
   |
LL | fn cycle2() {
   | ^^^^^^^^^^^
...
LL |     cycle1();
   |     -------- call site completing the cycle
</code></pre></div>


<p>I can't find a way to access the "sub"-diagnostic to attach labels. Is that possible?</p>



<a name="205704810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205704810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205704810">(Aug 02 2020 at 00:47)</a>:</h4>
<p>does <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Diagnostic.html#method.highlighted_note">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Diagnostic.html#method.highlighted_note</a> with <code>Style::LabelSecondary</code> do what you want?</p>



<a name="205704852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205704852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205704852">(Aug 02 2020 at 00:48)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> ^</p>



<a name="205704856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205704856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205704856">(Aug 02 2020 at 00:48)</a>:</h4>
<p>that seems to be for piecing a message together from parts</p>



<a name="205704861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205704861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205704861">(Aug 02 2020 at 00:49)</a>:</h4>
<p>and doesn't take a span</p>



<a name="205704862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205704862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205704862">(Aug 02 2020 at 00:49)</a>:</h4>
<p>ah hmm good point</p>



<a name="205704911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205704911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205704911">(Aug 02 2020 at 00:50)</a>:</h4>
<p>if you used <code>span_note</code> for 'call site completing the cycle' you could have the ordering be the way you want</p>



<a name="205704917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205704917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205704917">(Aug 02 2020 at 00:51)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error: function cannot return without recursing
  --&gt; $DIR/lint-unconditional-recursion.rs:152:1
   |
LL | fn cycle1() {
   | ^^^^^^^^^^^ cannot return without recursing
LL |     cycle2();
   |     -------- call into the next function in the cycle
   |
note: next function in the cycle
  --&gt; $DIR/lint-unconditional-recursion.rs:156:1
   |
LL | fn cycle2() {
   | ^^^^^^^^^^^
...
note: call site completing the cycle
LL |     cycle1();
   |     --------
</code></pre></div>



<a name="205704923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205704923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205704923">(Aug 02 2020 at 00:51)</a>:</h4>
<p>yeah</p>



<a name="205704929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205704929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205704929">(Aug 02 2020 at 00:51)</a>:</h4>
<p>ah, wait, the span_note can be used with a <code>MultiSpan</code>, which includes labels</p>



<a name="205704987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205704987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205704987">(Aug 02 2020 at 00:53)</a>:</h4>
<p>seems fairly hard to integrate into what I have though</p>



<a name="205741403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205741403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205741403">(Aug 02 2020 at 19:49)</a>:</h4>
<p>opened <a href="https://github.com/rust-lang/rust/issues/75067">#75067</a> for now, let's see if that even works without being horribly slow</p>
<p>cc <span class="user-mention" data-user-id="119009">@eddyb</span> in case you're interested in this</p>



<a name="205763554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205763554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205763554">(Aug 03 2020 at 06:38)</a>:</h4>
<p>perfbot doesn't like it. I really think we should find a single scheme for inlining and unconditional_recursion</p>



<a name="205763577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Making%20%60unconditional_recursion%60%20work%20across%20function%20calls/near/205763577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Making.20.60unconditional_recursion.60.20work.20across.20function.20calls.html#205763577">(Aug 03 2020 at 06:39)</a>:</h4>
<p>While the current state of my PR has a 4% regression, we likely can figure something out to get rid of that, at which point the <code>unconditional_recursion</code> check would just become a single query invocation more expensive.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>